package org.deschutter.hibernate;

import javax.persistence.*;

/**
 * User: Berten De Schutter
 * Date: 01-Oct-2009
 * Time: 13:40:13
 */
@Entity
@Table(catalog = "scimitar", name = "unit")
public class Unit {
    private long id;

    @Id
    @Column(name = "ID")
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    private byte shipId;

    @Basic
    @Column(name = "ship_id")
    public byte getShipId() {
        return shipId;
    }

    public void setShipId(byte shipId) {
        this.shipId = shipId;
    }

    private int amount;

    @Basic
    @Column(name = "amount")
    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Unit unit = (Unit) o;

        if (amount != unit.amount) return false;
        if (id != unit.id) return false;
        if (shipId != unit.shipId) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = (int) (id ^ (id >>> 32));
        result = 31 * result + (int) shipId;
        result = 31 * result + amount;
        return result;
    }

    private Scans scansByScanId;

    @ManyToOne
    @JoinColumn(name = "scan_id", referencedColumnName = "ID", nullable = false)
    public Scans getScansByScanId() {
        return scansByScanId;
    }

    public void setScansByScanId(Scans scansByScanId) {
        this.scansByScanId = scansByScanId;
    }
}
